package com.example.ireader;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

/**
 * Created by Administrator on 2017/12/6.
 */

public class Category_First_Right_Fragment_Adapter extends RecyclerView.Adapter<Category_First_Right_Fragment_Adapter.ViewHolder> {
    private List<Category_First_Right_Fragment_Item> mItemList;

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView Item_Name;
        ImageView Item_ImageID;

        public ViewHolder (View view) {
            super(view);
            Item_ImageID =(ImageView)view.findViewById(R.id.category_first_right_fragment_item_imageID) ;
            Item_Name = (TextView) view.findViewById(R.id.category_first_right_fragment_item_name);
        }
    }

    public Category_First_Right_Fragment_Adapter(List<Category_First_Right_Fragment_Item> itemList){
        mItemList = itemList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.category_first_right_fragment_item,parent,false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(Category_First_Right_Fragment_Adapter.ViewHolder holder, int position) {
        Category_First_Right_Fragment_Item item = mItemList.get(position);
        holder.Item_Name.setText(item.get_Category_First_Right_Fragment_Item_Name());
        holder.Item_ImageID.setImageResource(item.get_Category_First_Right_Fragment_Item_imageID());
    }

    @Override
    public int getItemCount() {
        return mItemList.size();
    }

}
